package com.cy.sys.log.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cy.sys.Aop.ancution.clearCache;
import com.cy.sys.Aop.ancution.requestCache;
import com.cy.sys.log.Dao.SysDeptDao;
import com.cy.sys.log.service.SysDeptSerivce;
import com.cy.sys.log.service.exception.ServiceException;
import com.cy.sys.pojo.NodeMenu;
import com.cy.sys.pojo.SysDepts;
@Service
public class SysDeptServiceImpl implements SysDeptSerivce{
	@Autowired
	private SysDeptDao sysdeptdao;
	
	//修改操作
	@clearCache
	@Override
	public int updateDeptById(SysDepts sysdepts) {
		if(sysdepts==null)
			throw new IllegalArgumentException("对不起你的参数无效");
		int ros = sysdeptdao.updateDeptById(sysdepts);
		if(ros==0)
			throw new ServiceException("未修改成功");
		return ros;
	}

	@clearCache
	@Override
	public int insertDept(SysDepts sysdepts) {
		if(sysdepts==null)
			throw new IllegalArgumentException("您的参数不合法");
		int ros = sysdeptdao.insertDept(sysdepts);
		if(ros==0)
			throw new ServiceException("对不起你的数据新增异常");
		return ros;
	}
	
	
	@Override
	public List<NodeMenu> selectfindzTee() {
		List<NodeMenu> zTee = sysdeptdao.selectfindzTee();
		if(zTee==null)
			throw new ServiceException("没有查询到");
		return zTee;
	}
	
	@Override
	@requestCache(key="dept")
	public List<SysDepts> findAllDepts() {
		List<SysDepts> depts = sysdeptdao.findAllDepts();
		if(depts==null)
			throw new ServiceException("没有找到信息");
		return depts;
	}


}
